﻿using System.Collections.Generic;
using System;

namespace Bowlus.FrontEnd
{
    public class ArrFarm : IComparable
    {
        public ArrFarm()
        {
            Servers = new List<ArrFarmServer>();
        }

        public string Name { get; set; }

        public List<ArrFarmServer> Servers { get; set; }

        // TODO: we only compare farm name. Need a better way to decide wether the farm changes.
        // if our current approach, where each farm only contains one server and farm name=server name, this works.
        public int CompareTo(object obj)
        {
            if (obj != null && obj is ArrFarm)
            {
                ArrFarm af = obj as ArrFarm;
                return Name.CompareTo(af.Name);
            }
            return -1;
        }
    }

    public class ArrFarmServer
    {
        public Uri Endpoint { get; set; }

        public string InstanceId { get; set; }

        public bool EqualsAFS(ArrFarmServer fs)
        {
            if (fs.Endpoint.Equals(Endpoint) && fs.InstanceId == InstanceId)
                return true;
            return false;
        }
    }

}
